package com.td.module.system.dal.mysql.video;

import com.td.framework.common.pojo.PageResult;
import com.td.framework.mybatis.core.mapper.BaseMapperX;
import com.td.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.td.module.system.controller.admin.video.vo.video.VideoExportReqVO;
import com.td.module.system.controller.admin.video.vo.video.VideoPageReqVO;
import com.td.module.system.dal.dataobject.video.VideoDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 萤石账号管理 Mapper
 *
 * @author 王翔翔
 */
@Mapper
public interface VideoMapper extends BaseMapperX<VideoDO> {

    default PageResult<VideoDO> selectPage(VideoPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<VideoDO>()
                .eqIfPresent(VideoDO::getAppKey, reqVO.getAppKey())
                .eqIfPresent(VideoDO::getAppSecret, reqVO.getAppSecret())
                .eqIfPresent(VideoDO::getAccessToken, reqVO.getAccessToken())
                .orderByDesc(VideoDO::getId));
    }

    default List<VideoDO> selectList(VideoExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<VideoDO>()
                .eqIfPresent(VideoDO::getAppKey, reqVO.getAppKey())
                .eqIfPresent(VideoDO::getAppSecret, reqVO.getAppSecret())
                .eqIfPresent(VideoDO::getAccessToken, reqVO.getAccessToken())
                .orderByDesc(VideoDO::getId));
    }

    default VideoDO selectByAppKey(String appKey){
        return selectOne(VideoDO::getAppKey,appKey);
    }
}
